from GetDatas.GetInvestIndex import get_data
from config.InvestDict import IndexData
import os
from utils.cacular_date import cacular_date, hriline_2_slash
import datetime
from config.indexcode import code_list, currency_list
from GetDatas.GetDataFromCcxt import crawl_bybit_datas


def get_datas(date_start, date_yestoday):
    for currency in currency_list:
        currency = currency.replace("USDT", "/USDT")
        crawl_bybit_datas(currency, date_start, date_yestoday)

    date_start = hriline_2_slash(cacular_date(date_start, -1))
    date_yestoday = hriline_2_slash(date_yestoday)

    current_path = os.path.dirname(os.path.dirname(__file__))
    for code in code_list:
        save_file_path = os.path.join(current_path, "data/" + code) + '.csv'
        df = get_data(date_start, date_yestoday, IndexData[code])
        df.to_csv(save_file_path)